package com.foreveross.project.usercenterserver.security.config;

import com.foreveross.project.usercenterserver.common.constant.GlobalConstant;
import com.foreveross.project.usercenterserver.common.utils.R;
import org.springframework.http.ResponseEntity;
import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator;
import org.springframework.stereotype.Component;

/**
 *
 * 自定义资源失败异常信息
 * @author: yz
 * @Date: 2019/8/1 1:21 PM
 */
@Component("customWebResponseExceptionTranslator")
public class CustomWebResponseExceptionTranslator implements WebResponseExceptionTranslator {

    @Override
    public ResponseEntity translate(Exception e) throws Exception {
        return ResponseEntity.ok(R.error(GlobalConstant.ERROR_DENIED,e.getMessage()));
    }
}